package com.module_live.view;

import android.app.Activity;
import android.content.Context;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.BaseExpandableListAdapter;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.bumptech.glide.Glide;
import com.lib.app.CodeUtil;
import com.lib.fastkit.db.shared_prefrences.SharedPreferenceManager;
import com.lib.fastkit.http.ok.HttpUtils;
import com.lib.fastkit.utils.json_deal.lib_mgson.MGson;
import com.lib.fastkit.utils.log.LogUtil;
import com.lib.fastkit.utils.share.tool.StringUtil;
import com.lib.fastkit.utils.time_deal.TimeUtils;
import com.lib.fastkit.views.circle_image.niv.NiceImageView;
import com.lib.fastkit.views.recyclerview.tool.MyLinearLayoutManager;
import com.lib.fastkit.views.recyclerview.zhanghongyang.base.ViewHolder;
import com.lib.http.call_back.HttpNormalCallBack;
import com.lib.ui.adapter.BaseAdapter;
import com.lib.utls.glide.GlideConfig;
import com.luck.picture.lib.tools.ToastManage;
import com.module_live.R;
import com.module_live.activity.CoachStudyLivingActivity;
import com.module_live.bean.coachstudy.SetAndShowWorkBean;
import com.module_live.bean.coachstudy.TeacherSetWorkDescribeBean;
import com.module_live.bean.coachstudy.UploadHomeWorkImgBean;
import com.zyyoona7.popup.EasyPopup;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

public class StudySetWorkPopup {


    private Activity activity;

    String identify = "";
    StudentWorkListAdapter workListAdapter;
    List<SetAndShowWorkBean.ObjBean> uploadWorkList = new ArrayList<>();

    private String[] gradeArr;
    private String[] workArr;

    public StudySetWorkPopup(Activity activity) {


        this.activity = activity;

        initPopuPopu();
    }

    private EasyPopup popu;

    private void initPopuPopu() {

        popu = EasyPopup.create()
                .setContext(activity)
                .setContentView(R.layout.popup_study_worklist)
                .setWidth(WindowManager.LayoutParams.FILL_PARENT)
                .setHeight(WindowManager.LayoutParams.FILL_PARENT)
                .setOnViewListener(new EasyPopup.OnViewListener() {
                    @Override
                    public void initViews(View view, EasyPopup basePopup) {

                        initView(view);

                    }

                })
                .setFocusAndOutsideEnable(true)
                .apply();

    }

    public ExpandableListView elWorkList;

    private void initView(View view) {

        identify = SharedPreferenceManager.getInstance(activity).getUserCache().getUserIdentity();
        gradeArr = activity.getResources().getStringArray(R.array.array_choose_settime);
        workArr = activity.getResources().getStringArray(R.array.array_choose_setwork);

        elWorkList = view.findViewById(R.id.el_work);

        workListAdapter = new StudentWorkListAdapter();
        elWorkList.setAdapter(workListAdapter);

        elWorkList.setGroupIndicator(null);
    }

    public void dismiss() {
        popu.dismiss();
    }

    public void showAnswerPopuPopu(View view) {

        popu.showAtLocation(view, Gravity.CENTER, 0, 0);

    }

    public View parntView;

    public void updateSetWorkData(View parentVIew) {

        this.parntView = parentVIew;

        if ("1".equals(identify)) {
            getStudentCoachWorkData();
        } else if ("2".equals(identify)) {
            getTeacherSetWorkData();
        }

    }

    class StudentWorkListAdapter extends BaseExpandableListAdapter {

        @Override
        public int getGroupCount() {
            return uploadWorkList.size();
        }

        @Override
        public Object getGroup(int groupPosition) {
            return uploadWorkList.get(groupPosition);
        }

        @Override
        public long getGroupId(int groupPosition) {
            return groupPosition;
        }

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
            GroupViewHolder groupViewHolder;
            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_study_setwork_top, null);
                groupViewHolder = new GroupViewHolder(convertView);
                convertView.setTag(groupViewHolder);
            } else {
                groupViewHolder = (GroupViewHolder) convertView.getTag();
            }
            SetAndShowWorkBean.ObjBean objBean = uploadWorkList.get(groupPosition);
            //设置用户头像及用户姓名
            if (StringUtil.isNotEmpty(objBean.getPhoto_url(), true)) {
                Glide.with(activity)
                        .load(objBean.getPhoto_url())
                        .apply(GlideConfig.getCircleOptions())
                        .into(groupViewHolder.niceImageView);
            }
            if (StringUtil.isNotEmpty(objBean.getUser_name(), true)) {
                groupViewHolder.tvName.setText(objBean.getUser_name());
            }

            if (isExpanded) {
                groupViewHolder.ivArrow.setBackgroundResource(R.mipmap.icon_up);
            } else {
                groupViewHolder.ivArrow.setBackgroundResource(R.mipmap.icon_down);
            }

            return convertView;
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return 1;
        }

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            return uploadWorkList.get(groupPosition);
        }

        @Override
        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }

        @Override
        public boolean hasStableIds() {
            return false;
        }

        @Override
        public View getChildView(final int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
            final ChildViewHolder childViewHolder;
            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_study_setwork_rv, null);
                childViewHolder = new ChildViewHolder(convertView);
                convertView.setTag(childViewHolder);
            } else {
                childViewHolder = (ChildViewHolder) convertView.getTag();
            }

            if (uploadWorkList.get(groupPosition).getImage_hash() != null &&
                    uploadWorkList.get(groupPosition).getImage_hash().size() > 0) {

                StudySetWorkAdapter imgAdapter = new StudySetWorkAdapter(
                        activity, uploadWorkList.get(groupPosition).getImage_hash());
                MyLinearLayoutManager manager = new MyLinearLayoutManager(activity, MyLinearLayoutManager.HORIZONTAL, false);
                childViewHolder.rvWork.setLayoutManager(manager);
                childViewHolder.rvWork.setAdapter(imgAdapter);
            }

            if ("2".equals(identify)) {
                childViewHolder.linConfirm.setVisibility(View.GONE);
//                childViewHolder.tvConfirm.setVisibility(View.GONE);
            }

            childViewHolder.tvConfirm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO: 2020/10/9 0009 将保存的该学生所有作业设置情况装载容器传递到后台
                    if (workDescribeList.size() > 0) {
                        //如果已设置完成作业容器数据不等于或者小于所有问题图片的数据，需要先设置完所有作业
                        if (workDescribeList.size() != uploadWorkList.get(groupPosition).getImage_hash().size() ||
                                workDescribeList.size() < uploadWorkList.get(groupPosition).getImage_hash().size()) {

                            ToastManage.s(activity, "请先设置完所有的作业再提交哦！");
                        } else {
                            String describe = MGson.newGson().toJson(workDescribeList);

                            //发送指定作业描述到后台
                            sendStudentWorkDescribeToService(describe, groupPosition, uploadWorkList);
                        }

                    } else {
                        ToastManage.s(activity, "请先给作业设置内容哦！");
                    }

                }
            });

            return convertView;
        }

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return false;
        }
    }

    private void sendStudentWorkDescribeToService(String describeJson, final int groupPosition, final List<SetAndShowWorkBean.ObjBean> uploadWorkList) {

        HttpUtils.with(activity)
                .addParam("requestType", "SET_STUDENT_HOMEWORK_TIME")
                .addParam("token", SharedPreferenceManager.getInstance(activity).getUserCache().getUserToken())
                .addParam("course_id", CoachStudyLivingActivity.course_id)
                .addParam("student_id", uploadWorkList.get(groupPosition).getUser_id())
                .addParam("image_time", describeJson)
                .execute(new HttpNormalCallBack<UploadHomeWorkImgBean>() {
                    @Override
                    public void onSuccess(UploadHomeWorkImgBean result) {

                        if (CodeUtil.CODE_200 == result.getCode()) {

                            ToastManage.s(activity, "作业设置成功");
                            workDescribeList.clear();

                            //清楚该条数据，并刷新适配器
                            uploadWorkList.remove(groupPosition);
                            workListAdapter.notifyDataSetChanged();

                        }
                    }

                    @Override
                    public void onError(String e) {

                    }
                });

    }


    static class GroupViewHolder {
        public NiceImageView niceImageView;
        public TextView tvName;
        public ImageView ivArrow;

        public GroupViewHolder(View view) {

            niceImageView = view.findViewById(R.id.iv_user);
            tvName = view.findViewById(R.id.tv_name);
            ivArrow = view.findViewById(R.id.iv_arrow);
        }

    }

    static class ChildViewHolder {

        public RecyclerView rvWork;
        public TextView tvConfirm;
        public LinearLayout linConfirm;


        public ChildViewHolder(View view) {

            rvWork = view.findViewById(R.id.rv_work);
            tvConfirm = view.findViewById(R.id.tv_comfirm);
            linConfirm = view.findViewById(R.id.lin_confirm);
        }
    }


    // TODO: 2020/9/29 0029   作业图片适配器
    class StudySetWorkAdapter extends BaseAdapter<SetAndShowWorkBean.ObjBean.ImageHashBean> {

        public StudySetWorkAdapter(Context context, List<SetAndShowWorkBean.ObjBean.ImageHashBean> mData) {
            super(context, mData);

        }

        @Override
        public int getLayoutId() {
            return R.layout.item_study_setwork_rv_child;
        }

        @Override
        protected void toBindViewHolder(final ViewHolder holder, final int position, final List<SetAndShowWorkBean.ObjBean.ImageHashBean> mData) {

            holder.setIsRecyclable(false);

            final SetAndShowWorkBean.ObjBean.ImageHashBean imageHashBean = mData.get(position);

            ImageView ivQuesImg = holder.getView(R.id.iv_quesimg);

            final LinearLayout linTeacher = holder.getView(R.id.lin_teacher);
            final Spinner spinTeacherTime = holder.getView(R.id.new_spin_grade);
            ImageView ivSelect = holder.getView(R.id.new_iv_grade);
            TextView tvSure = holder.getView(R.id.tv_srue);
//            final EditText etTeacherContent = holder.getView(R.id.et_content);
            final Spinner spinTeacherWork = holder.getView(R.id.new_spin_work);

            final LinearLayout linStudnet = holder.getView(R.id.lin_student);
            final TextView tvContent = holder.getView(R.id.tv_stu_content);
            final TextView tvTime = holder.getView(R.id.tv_stu_time);

            //设置问题图片
            if (StringUtil.isNotEmpty(imageHashBean.getImage_hash(), true)) {
                Glide.with(activity)
                        .load(imageHashBean.getImage_hash())
                        .apply(GlideConfig.getRoundOptions(10))
                        .into(ivQuesImg);
            }

            ivQuesImg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    ZoomImagePopupUtils imagePopupUtils = new ZoomImagePopupUtils(activity);
                    imagePopupUtils.setZoomImage("otheer", imageHashBean.getImage_hash());
                    imagePopupUtils.showAnswerPopuPopu(parntView);
                }
            });

            //根据身份判断显示输入内容还是显示内容以及设置时间还是显示时间
            if ("2".equals(identify)) {
                linStudnet.setVisibility(View.VISIBLE);
                linTeacher.setVisibility(View.GONE);

                if (StringUtil.isNotEmpty(imageHashBean.getExplanation(), true)) {
                    tvContent.setText(imageHashBean.getExplanation());
                }
                if (StringUtil.isNotEmpty(imageHashBean.getTime(), true)) {
                    tvTime.setText(imageHashBean.getTime());
                }

            } else if ("1".equals(identify)) {

//                etTeacherContent.clearFocus();

                initSpinner(spinTeacherTime, spinTeacherWork);

//                initEditDescribe(etTeacherContent);

                tvSure.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

//                        String work = etTeacherContent.getText().toString().trim();
//                        String work = "111111111";
                        if (TextUtils.isEmpty(chooseWorkStr)) {
                            ToastManage.s(activity, "请先给学生设置作业内容哦！");
                        } else {
                            if (!StringUtil.isNotEmpty(chooseTimeStr, true)) {
                                ToastManage.s(activity, "请为作业分配完成时间哦！");
                            } else {

                                //调用接口，完成一次作业分布
                                //上传成功后，将输入框、设置时间、确定隐藏，显示已设置的内容
                                String setTime = chooseTimeStr;
                                String describe = chooseWorkStr;

                                TeacherSetWorkDescribeBean describeBean = null;
                                if (StringUtil.isNotEmpty(setTime, true) && StringUtil.isNotEmpty(describe, true)) {
//                                if (StringUtil.isNotEmpty(setTime, true)) {
                                    describeBean = new TeacherSetWorkDescribeBean();
                                    describeBean.setImage_hash(imageHashBean.getImage_hash());
                                    describeBean.setTime(setTime);
                                    describeBean.setExplanation(describe);
                                }
                                workDescribeList.add(describeBean);
                                describeBean = null;

                                tvContent.setText(describe);
                                tvTime.setText(setTime);
                                linTeacher.setVisibility(View.GONE);
                                linStudnet.setVisibility(View.VISIBLE);

//                                InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
//                                imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

                            }
                        }
                    }
                });

            }

        }
    }

    private void initEditDescribe(final EditText etTeacherContent) {

//        TextWatcher watcher = new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
//
//                etTeacherContent.setTag(etTeacherContent.getTag());
//            }
//        };
//
//        etTeacherContent.addTextChangedListener(watcher);

        etTeacherContent.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (s.length() > 0) {
                    LogUtil.e("设置作业的文本为：" + s);
                }
            }
        });

        etTeacherContent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(etTeacherContent, InputMethodManager.SHOW_FORCED);
            }
        });

    }


    public String chooseTimeStr = "";
    public String chooseWorkStr = "";

    private void initSpinner(Spinner spinTeacherTime, Spinner spinTeacherWork) {

        spinTeacherTime.setFocusable(false);
        spinTeacherTime.setAdapter(new TvArrayAdapter(activity, gradeArr));
        spinTeacherTime.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                String item = (String) parent.getItemAtPosition(position);
                if (StringUtil.isNotEmpty(item, true)) {
                    chooseTimeStr = item;
                }
                LogUtil.e("选中的时间为：" + item);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        spinTeacherWork.setFocusable(false);
        spinTeacherWork.setAdapter(new TvArrayAdapter(activity, workArr));
        spinTeacherWork.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                String item = (String) parent.getItemAtPosition(position);
                if (StringUtil.isNotEmpty(item, true)) {
                    chooseWorkStr = item;
                }
                LogUtil.e("选中的作业为：" + item);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

//        spinTeacherTime.setDropDownVerticalOffset(35);
//
//        try {
//            Field popup = Spinner.class.getDeclaredField("mPopup");
//            popup.setAccessible(true);
//            // Get private mPopup member variable and try cast to ListPopupWindow
//            ListPopupWindow popupWindow = (ListPopupWindow) popup.get(spinTeacherTime);
//            // Set popupWindow height to 500px
//            popupWindow.setHeight(200);
//        } catch (Exception e) {
//            // silently fail...
//            LogUtil.e("Exception为：" + e.getMessage().toString());
//        }
    }

    //某一个学生作业图片，描述，时间的综合容器
    List<TeacherSetWorkDescribeBean> workDescribeList = new ArrayList<>();

    private TimePickerView pvTime;

    private void initTimePicker(final TextView tvTime) {

        pvTime = new TimePickerBuilder(activity, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {//选中事件回调

                String birth = TimeUtils.getDateStr(date, TimeUtils.FORMAT_1);
//                addUpdateInfo("birthday_date", birth);

                //将时间转化为int，方便播放时设置弹出时间
                if (StringUtil.isNotEmpty(birth, true)) {
                    String[] time = birth.split(":");

//                    if ("00".equals(time[0])) {
//                        quesTime = Integer.parseInt(time[1]) * 60 + Integer.parseInt(time[2]);
//                    } else {
//                        quesTime = Integer.parseInt(time[0]) * 3600 + Integer.parseInt(time[1]) * 60 + Integer.parseInt(time[2]);
//                    }
//                    LogUtil.e("选择完成作业的时间为：" + birth + "转化为int之后的值为：" + quesTime);
                    LogUtil.e("选择完成作业的时间为：" + birth);
                }

                tvTime.setText(birth);
                tvTime.setTextColor(activity.getResources().getColor(R.color.color_666666));
            }
        }).setType(new boolean[]{false, false, false, true, true, true})// 默认全部显示
//                .setDate(selectedDate)// 如果不设置的话，默认是系统时间*/
//                .setRangDate(startDate, endDate)//起始终止年月日设定
                .setLabel("年", "月", "日", "时", "分", "秒")//默认设置为年月日时分秒
                .isCenterLabel(true) //是否只显示中间选中项的label文字，false则每项item全部都带有label。
                .isDialog(false)//是否显示为对话框样式
                .setCancelText("取消")//取消按钮文字
                .setSubmitText("确认")//确认按钮文字
                .setTitleSize(20)//标题文字大小
                .setTitleText("问题出现时间")//标题文字
                .setOutSideCancelable(false)//点击屏幕，点在控件外部范围时，是否取消显示
                .setTitleColor(activity.getResources().getColor(R.color.base_title))//标题文字颜色
                .setSubmitColor(activity.getResources().getColor(R.color.base_blue))//确定按钮文字颜色
                .setCancelColor(activity.getResources().getColor(R.color.base_blue))//取消按钮文字颜色
                .setTitleBgColor(activity.getResources().getColor(R.color.white))//标题背景颜色 Night mode
                .setBgColor(activity.getResources().getColor(R.color.base_white))//滚轮背景颜色 Night mode
                .setOutSideCancelable(true)
                .build();

        //设置默认时间
        Calendar c = Calendar.getInstance();
        c.set(c.get(Calendar.YEAR) * 0,
                c.get(Calendar.MONTH) * 0,
                c.get(Calendar.DATE) * 0,
                c.get(Calendar.HOUR_OF_DAY),
                c.get(Calendar.MINUTE),
                c.get(Calendar.SECOND));
        pvTime.setDate(c);

    }


    /**
     * 获取学生最开始上传的家庭作业
     */
    public void getStudentCoachWorkData() {

        HttpUtils.with(activity)
                .addParam("requestType", "STUDENT_WORK_RECORD")
                .addParam("token", SharedPreferenceManager.getInstance(activity).getUserCache().getUserToken())
                .addParam("course_id", CoachStudyLivingActivity.course_id)
                .addParam("edit_or_view", 1)
                .addParam("recording_manner", 0)
                .execute(new HttpNormalCallBack<SetAndShowWorkBean>() {
                    @Override
                    public void onSuccess(SetAndShowWorkBean result) {
                        if (CodeUtil.CODE_200 == result.getCode()) {

                            if (uploadWorkList.size() > 0) {
                                uploadWorkList.clear();
                            }

                            uploadWorkList.addAll(result.getObj());
                            workListAdapter.notifyDataSetChanged();
                        }

                    }

                    @Override
                    public void onError(String e) {

                    }
                });
    }

    /**
     * 获取老师设置的家庭作业时间及描述
     */
    public void getTeacherSetWorkData() {

        HttpUtils.with(activity)
                .addParam("requestType", "STUDENTS_VIEW_ASSIGNMENTS")
                .addParam("token", SharedPreferenceManager.getInstance(activity).getUserCache().getUserToken())
                .addParam("course_id", CoachStudyLivingActivity.course_id)
                .execute(new HttpNormalCallBack<SetAndShowWorkBean>() {
                    @Override
                    public void onSuccess(SetAndShowWorkBean result) {
                        if (CodeUtil.CODE_200 == result.getCode()) {

                            if (uploadWorkList.size() > 0) {
                                uploadWorkList.clear();
                            }

                            uploadWorkList.addAll(result.getObj());
                            workListAdapter.notifyDataSetChanged();
                        }

                    }

                    @Override
                    public void onError(String e) {

                    }
                });
    }

    public class TvArrayAdapter extends android.widget.BaseAdapter {

        private String[] mStringArray;
        private Context context;

        public TvArrayAdapter(Context context, String[] mStringArray) {
            this.context = context;
            this.mStringArray = mStringArray;
        }

        @Override
        public int getCount() {
            return mStringArray.length;
        }

        @Override
        public Object getItem(int position) {
            return mStringArray[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {

//            LayoutInflater inflate1 = LayoutInflater.from(context);
//            View view = inflate1.inflate(R.layout.popup_gradesubjselect, null);
//
//            RecyclerView rvSelect = view.findViewById(R.id.rv_select);
//            SelectAdapter selectAdapter = new SelectAdapter(context, mStringArray);
//            MyLinearLayoutManager manager = new MyLinearLayoutManager(getActivity());
//            rvSelect.setLayoutManager(manager);
//            rvSelect.setAdapter(selectAdapter);

            LayoutInflater _LayoutInflater = LayoutInflater.from(context);
            convertView = _LayoutInflater.inflate(R.layout.item_select, null);
            if (convertView != null) {
                TextView tv = (TextView) convertView.findViewById(R.id.tv_text);
                tv.setText(mStringArray[position]);
            }
            return convertView;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            LayoutInflater _LayoutInflater = LayoutInflater.from(context);
            convertView = _LayoutInflater.inflate(R.layout.item_select, null);
            if (convertView != null) {
                TextView tv = (TextView) convertView.findViewById(R.id.tv_text);
                tv.setText(mStringArray[position]);
            }
            return convertView;
        }
    }


    class TimeChooseSpinnerAdapter implements AdapterView.OnItemSelectedListener {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    }


}
